home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Games / NetSprocketTest / init.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.6 KB  |  142 lines  |  [TEXT/CWIE]

  1. /***********************************************************************
  2. #
  3. #        init.c
  4. #
  5. #        basic initialization code.
  6. #
  7. #        Author: Michael Marinkovich
  8. #                Apple Developer Technical Support
  9. #
  10. #
  11. #        Modification History: 
  12. #
  13. #            6/4/95        MWM     Initial coding                     
  14. #            10/12/95    MWM        cleaned up
  15. #
  16. #        Copyright © 1992-95 Apple Computer, Inc., All Rights Reserved
  17. #
  18. #
  19. ***********************************************************************/
  20.  
  21.  
  22. #include <AppleEvents.h>
  23. #include <Displays.h>
  24. #include <Events.h>
  25. #include <Fonts.h>
  26. #include <Gestalt.h>
  27. #include <Menus.h>
  28. #include <OSUtils.h>
  29.  
  30. #include "App.h"
  31. #include "Proto.h"
  32. #include "NetStuff.h"
  33.  
  34. extern Boolean             gHasDMTwo;
  35. extern Boolean             gHasDrag;
  36. extern Boolean            gInBackground;
  37. extern short            gWindCount;
  38.  
  39.  
  40. //----------------------------------------------------------------------
  41. //
  42. //    Initialize - the main entry point for the initialization
  43. //
  44. //
  45. //----------------------------------------------------------------------
  46.  
  47. OSErr Initialize(void)
  48. {
  49.     OSErr        err = noErr;
  50.     OSStatus    status;    
  51.     
  52.     ToolBoxInit();
  53.     CheckEnvironment();
  54.     err = InitApp();
  55.     status = InitNetworking('BLAm');
  56.     
  57.     return err;
  58. }
  59.  
  60.  
  61. //----------------------------------------------------------------------
  62. //
  63. //    ToolBoxInit - initialization all the needed managers
  64. //
  65. //
  66. //----------------------------------------------------------------------
  67.  
  68. void ToolBoxInit(void)
  69. {
  70.  
  71.     InitGraf(&qd.thePort);
  72.     InitFonts();
  73.     InitWindows();
  74.     InitMenus();
  75.     TEInit();
  76.     InitDialogs(nil);
  77.     InitCursor();
  78.         
  79.     FlushEvents(everyEvent, 0);
  80.  
  81. }
  82.  
  83.  
  84. //----------------------------------------------------------------------
  85. //
  86. //    CheckEnvironment - make sure we can run with current sys and managers.
  87. //                       Also initialize globals - have drag & drop
  88. //                      
  89. //----------------------------------------------------------------------
  90.  
  91. void CheckEnvironment(void)
  92. {
  93.     
  94.     // your stuff here
  95. }
  96.  
  97.  
  98. //----------------------------------------------------------------------
  99. //
  100. //    InitApp - initialization all the application specific stuff
  101. //
  102. //
  103. //----------------------------------------------------------------------
  104.  
  105. OSErr InitApp(void)
  106. {
  107.     OSErr                err;
  108.  
  109.     // init AppleEvents
  110.     err = AEInit();
  111.     MenuSetup();
  112.  
  113.     // init any globals
  114.     gWindCount = 1;
  115.  
  116.     return err;
  117.     
  118. }
  119.  
  120.  
  121. //----------------------------------------------------------------------
  122. //
  123. //    MenuSetup - 
  124. //
  125. //
  126. //----------------------------------------------------------------------
  127.  
  128. void MenuSetup(void)
  129. {
  130.     Handle            menu;
  131.         
  132.         
  133.     menu = GetNewMBar(rMBarID);        //    get our menus from resource
  134.     SetMenuBar(menu);
  135.     DisposeHandle(menu);
  136.     AppendResMenu(GetMenuHandle(mApple ), 'DRVR');        //    add apple menu items
  137.  
  138.     DrawMenuBar();
  139.  
  140.         
  141. }
  142.